home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_mysql.idb / usr / freeware / include / mysql / m_string.h.z / m_string.h
C/C++ Source or Header  |  2002-10-07  |  8KB  |  245 lines

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This library is free software; you can redistribute it and/or
  4.    modify it under the terms of the GNU Library General Public
  5.    License as published by the Free Software Foundation; either
  6.    version 2 of the License, or (at your option) any later version.
  7.    
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU Library General Public
  14.    License along with this library; if not, write to the Free
  15.    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  16.    MA 02111-1307, USA */
  17.  
  18. /* There may be prolems include all of theese. Try to test in
  19.    configure with ones are needed? */
  20.  
  21. /*  This is needed for the definitions of strchr... on solaris */
  22.  
  23. #ifndef _m_string_h
  24. #define _m_string_h
  25. #ifndef __USE_GNU
  26. #define __USE_GNU                /* We want to use stpcpy */
  27. #endif
  28. #if defined(HAVE_STRINGS_H)
  29. #include <strings.h>
  30. #endif
  31. #if defined(HAVE_STRING_H)
  32. #include <string.h>
  33. #endif
  34.  
  35. /* Correct some things for UNIXWARE7 */
  36. #ifdef HAVE_UNIXWARE7_THREADS
  37. #undef HAVE_STRINGS_H
  38. #undef HAVE_MEMORY_H
  39. #define HAVE_MEMCPY
  40. #ifndef HAVE_MEMMOVE
  41. #define HAVE_MEMMOVE
  42. #endif
  43. #undef HAVE_BCMP
  44. #undef bcopy
  45. #undef bcmp
  46. #undef bzero
  47. #endif /* HAVE_UNIXWARE7_THREADS */
  48. #ifdef _AIX
  49. #undef HAVE_BCMP
  50. #endif
  51.  
  52. /*  This is needed for the definitions of bzero... on solaris */
  53. #if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
  54. #include <strings.h>
  55. #endif
  56.  
  57. /*  This is needed for the definitions of memcpy... on solaris */
  58. #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
  59. #include <memory.h>
  60. #endif
  61.  
  62. #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
  63. # define memcpy(d, s, n)    bcopy ((s), (d), (n))
  64. # define memset(A,C,B)        bfill((A),(B),(C))
  65. # define memmove(d, s, n)    bmove ((d), (s), (n))
  66. #elif defined(HAVE_MEMMOVE)
  67. # define bmove(d, s, n)        memmove((d), (s), (n))
  68. #else
  69. # define memmove(d, s, n)    bmove((d), (s), (n)) /* our bmove */
  70. #endif
  71.  
  72. /* Unixware 7 */
  73. #if !defined(HAVE_BFILL)
  74. # define bfill(A,B,C)           memset((A),(C),(B))
  75. # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
  76. #endif
  77.  
  78. #if !defined(HAVE_BCMP)
  79. # define bcopy(s, d, n)        memcpy((d), (s), (n))
  80. # define bcmp(A,B,C)        memcmp((A),(B),(C))
  81. # define bzero(A,B)        memset((A),0,(B))
  82. # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
  83. #endif
  84.  
  85. #if defined(__cplusplus) && !defined(OS2)
  86. extern "C" {
  87. #endif
  88.  
  89. #if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
  90. #define strmov(A,B) stpcpy((A),(B))
  91. #ifndef stpcpy
  92. extern char *stpcpy(char *, const char *);    /* For AIX with gcc 2.95.3 */
  93. #endif
  94. #endif
  95.  
  96. extern char NEAR _dig_vec[];        /* Declared in int2str() */
  97.  
  98. #ifdef BAD_STRING_COMPILER
  99. #define strmov(A,B)  (memccpy(A,B,0,INT_MAX)-1)
  100. #else
  101. #define strmov_overlapp(A,B) strmov(A,B)
  102. #define strmake_overlapp(A,B,C) strmake(A,B,C)
  103. #endif
  104.  
  105. #ifdef BAD_MEMCPY            /* Problem with gcc on Alpha */
  106. #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
  107. #else
  108. #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
  109. #endif
  110.  
  111. #ifdef MSDOS
  112. #undef bmove_allign
  113. #define bmove512(A,B,C) bmove_allign(A,B,C)
  114. #define my_itoa(A,B,C) itoa(A,B,C)
  115. #define my_ltoa(A,B,C) ltoa(A,B,C)
  116. extern    void bmove_allign(gptr dst,const gptr src,uint len);
  117. #endif
  118.  
  119. #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
  120. #define bmove512(A,B,C) memcpy(A,B,C)
  121. #endif
  122.  
  123.     /* Prototypes for string functions */
  124.  
  125. #if !defined(bfill) && !defined(HAVE_BFILL)
  126. extern    void bfill(gptr dst,uint len,pchar fill);
  127. #endif
  128.  
  129. #if !defined(bzero) && !defined(HAVE_BZERO)
  130. extern    void bzero(gptr dst,uint len);
  131. #endif
  132.  
  133. #if !defined(bcmp) && !defined(HAVE_BCMP)
  134. extern    int bcmp(const char *s1,const char *s2,uint len);
  135. #ifdef HAVE_purify
  136. extern    int my_bcmp(const char *s1,const char *s2,uint len);
  137. #define bcmp(A,B,C) my_bcmp((A),(B),(C))
  138. #endif
  139. #endif
  140.  
  141. #ifndef bmove512
  142. extern    void bmove512(gptr dst,const gptr src,uint len);
  143. #endif
  144.  
  145. #if !defined(HAVE_BMOVE) && !defined(bmove)
  146. extern    void bmove(char *dst, const char *src,uint len);
  147. #endif
  148.  
  149. extern    void bmove_upp(char *dst,const char *src,uint len);
  150. extern    void bchange(char *dst,uint old_len,const char *src,
  151.              uint new_len,uint tot_len);
  152. extern    void strappend(char *s,uint len,pchar fill);
  153. extern    char *strend(const char *s);
  154. extern  char *strcend(const char *, pchar);
  155. extern    char *strfield(char *src,int fields,int chars,int blanks,
  156.                int tabch);
  157. extern    char *strfill(my_string s,uint len,pchar fill);
  158. extern    uint strinstr(const char *str,const char *search);
  159. extern  uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
  160. extern    char *strkey(char *dst,char *head,char *tail,char *flags);
  161. extern    char *strmake(char *dst,const char *src,uint length);
  162. #ifndef strmake_overlapp
  163. extern    char *strmake_overlapp(char *dst,const char *src, uint length);
  164. #endif
  165.  
  166. #ifndef strmov
  167. extern    char *strmov(char *dst,const char *src);
  168. #endif
  169. extern    char *strnmov(char *dst,const char *src,uint n);
  170. extern    char *strsuff(const char *src,const char *suffix);
  171. extern    char *strcont(const char *src,const char *set);
  172. extern    char *strxcat _VARARGS((char *dst,const char *src, ...));
  173. extern    char *strxmov _VARARGS((char *dst,const char *src, ...));
  174. extern    char *strxcpy _VARARGS((char *dst,const char *src, ...));
  175. extern    char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
  176. extern    char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
  177. extern    char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
  178.  
  179. /* Prototypes of normal stringfunctions (with may ours) */
  180.  
  181. #ifdef WANT_STRING_PROTOTYPES
  182. extern char *strcat(char *, const char *);
  183. extern char *strchr(const char *, pchar);
  184. extern char *strrchr(const char *, pchar);
  185. extern char *strcpy(char *, const char *);
  186. extern int strcmp(const char *, const char *);
  187. #ifndef __GNUC__
  188. extern size_t strlen(const char *);
  189. #endif
  190. #endif
  191. #ifndef HAVE_STRNLEN 
  192. extern uint strnlen(const char *s, uint n);
  193. #endif
  194.  
  195. #if !defined(__cplusplus)
  196. #ifndef HAVE_STRPBRK
  197. extern char *strpbrk(const char *, const char *);
  198. #endif
  199. #ifndef HAVE_STRSTR
  200. extern char *strstr(const char *, const char *);
  201. #endif
  202. #endif
  203. extern int is_prefix(const char *, const char *);
  204.  
  205. /* Conversion rutins */
  206.  
  207. #ifdef USE_MY_ITOA
  208. extern char *my_itoa(int val,char *dst,int radix);
  209. extern char *my_ltoa(long val,char *dst,int radix);
  210. #endif
  211.  
  212. extern char *llstr(longlong value,char *buff);
  213. #ifndef HAVE_STRTOUL
  214. extern long strtol(const char *str, char **ptr, int base);
  215. extern ulong strtoul(const char *str, char **ptr, int base);
  216. #endif
  217.  
  218. extern char *int2str(long val,char *dst,int radix);
  219. extern char *int10_to_str(long val,char *dst,int radix);
  220. extern char *str2int(const char *src,int radix,long lower,long upper,
  221.              long *val);
  222. #if SIZEOF_LONG == SIZEOF_LONG_LONG
  223. #define longlong2str(A,B,C) int2str((A),(B),(C))
  224. #define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
  225. #define strtoll(A,B,C) strtol((A),(B),(C))
  226. #define strtoull(A,B,C) strtoul((A),(B),(C))
  227. #ifndef HAVE_STRTOULL
  228. #define HAVE_STRTOULL
  229. #endif
  230. #else
  231. #ifdef HAVE_LONG_LONG
  232. extern char *longlong2str(longlong val,char *dst,int radix);
  233. extern char *longlong10_to_str(longlong val,char *dst,int radix);
  234. #if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
  235. extern longlong strtoll(const char *str, char **ptr, int base);
  236. extern ulonglong strtoull(const char *str, char **ptr, int base);
  237. #endif
  238. #endif
  239. #endif
  240.  
  241. #if defined(__cplusplus) && !defined(OS2)
  242. }
  243. #endif
  244. #endif
  245.